<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div{
				width: 100px;
				height: 100px;
				background: red;
				position: absolute;
				left: 0;
				top: 0;
			}
		</style>
		
		<script>
			window.onload = function()
			{
				let div = document.querySelector('div');
				function fn(event)
				{
					
				}
					
				window.onclick = function(event)
				{
					let x = event.clientX - div.offsetLeft;
					let y = event.clientY - div.offsetTop;
					div.style.left = x + 'px';
					div.style.top = y + 'px';
					// fn();
					
					window.onmousemove = function(event)
					{
						x = event.clientX;
						y = event.clientY;
						
						div.style.left = x + 'px';
						div.style.top = y + 'px';
					}
					
					
					window.oncontextmenu = function()
					{
						window.onmousemove = null;
						return false;
					}
				}				
			}
		</script>
	</head>
	<body>
		<div></div>
	</body>
</html>